package com.xiubai.appforpda.jack.utils.permissionUtils;

import android.content.Context;
import android.hardware.Camera;
import android.util.Log;

/**
 * Description:
 *
 * @author zhaozp
 * @since 2016-08-12
 */
public class CameraPermissionCheckUtils {
    private static final String TAG = "CameraPermissionCheckUt";

    public static boolean checkCameraPermission(Context context) {
        boolean canUse = true;
        Camera mCamera = null;
        try {
            mCamera = Camera.open(0);
            mCamera.setDisplayOrientation(90);
           // setParameters 是针对魅族MX5 做的。MX5 通过Camera.open() 拿到的Camera
           // 对象不为null
           Camera.Parameters mParameters = mCamera.getParameters();
           mCamera.setParameters(mParameters);
        } catch (Exception e) {
            Log.e(TAG, Log.getStackTraceString(e));
            canUse = false;
        }
        if (mCamera!=null) {
            mCamera.release();
            mCamera = null;
        }
        return canUse;
    }
}
